home *** CD-ROM | disk | FTP | other *** search
- # (decoded with TMPL 13671)
- /* %filename% */
- /* Created %date% %time% by AppMaker */
-
- %If MPW%
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Controls.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Lists.h>
- #include <Menus.h>
- #include <TextEdit.h>
-
- %end if%
- #include "Globals.h"
- #include "ResourceDefs.h"
- %UsesFiles%
-
- #include "%unitname%.h"
-
- %If MPW%
- #include <Desk.h>
- #include <ToolUtils.h>
-
- %end if%
- #define nil 0L
- %If MPW%
-
- #pragma segment %unitname%
- %end if%
-
- /*----------*/
- void InitTitles ()
- {
- %InitTitles%
- } /*InitTitles*/
-
- /*----------*/
- void LoadMenus ()
- {
- %GetMenus%
-
- %InsertMenus%
-
- DrawMenuBar ();
- } /*LoadMenus*/
-
- /*----------*/
- void DoAbout (void);
- void DoAbout ()
- {
- short itemNr;
-
- itemNr = Alert (AboutID, nil);
- } /*DoAbout*/
-
- /*----------*/
- void DoApple (short itemNr);
- void DoApple (itemNr)
- short itemNr;
- {
- Str255 name;
- short refNum;
-
- switch (itemNr) {
- case AppleAbout:
- DoAbout ();
- break;
- default:
- GetItem (AppleMenu, itemNr, name);
- refNum = OpenDeskAcc (name);
- break;
- } /*switch*/
- } /*DoApple*/
-
- /*----------*/
- void DoMenu (menuChoice)
- long menuChoice;
- {
- short menuID;
- short itemNr;
-
- menuID = HiWord (menuChoice);
- itemNr = LoWord (menuChoice);
-
- switch (menuID) {
- case 0:
- /*Do nothing*/;
- break;
- %HandleMenus%
- } /*switch*/
-
- HiliteMenu (0);
- } /*DoMenu*/
-
- /*----------*/
- MenuHandle menu;
- Boolean menuBarChanged;
-
- /*----------*/
- void Enable (short itemNr,
- Boolean enabled);
-
- void Enable (itemNr, enabled)
- short itemNr;
- Boolean enabled;
- {
- if (enabled) {
- EnableItem (menu, itemNr);
- } else {
- DisableItem (menu, itemNr);
- }
- } /*Enable*/
-
- /*----------*/
- void EnableTitle (MenuHandle menu,
- Boolean enabled);
- void EnableTitle (menu, enabled)
- MenuHandle menu;
- Boolean enabled;
- {
- if (enabled != ((**menu).enableFlags & 1)) {
- menuBarChanged = true;
- }
- if (enabled) {
- EnableItem (menu, 0);
- } else {
- DisableItem (menu, 0);
- }
- } /*EnableTitle*/
-
- /*----------*/
- void UpdateMenus ()
- {
- WindowPeek frontPeek;
- Boolean isFront; /*is there a front window?*/
- Boolean isCur; /*is there a current window?*/
- Boolean isDirty; /*is it dirty?*/
- Boolean hasFile; /*does it have a file?*/
- Boolean isSelected; /*is anything selected?*/
- Boolean isDesk; /*is the front window a desk acc?*/
- Boolean isText; /*is there a current text field?*/
- Boolean isScrap; /*is there any scrap?*/
-
- menuBarChanged = false;
-
- isFront = (FrontWindow () != nil);
- isCur = (curWindow != nil);
- isDirty = false;
- hasFile = false;
- isSelected = false;
- if (isCur) {
- isDirty = cur->dirty;
- hasFile = (cur->fileNum != 0);
- }
-
- isDesk = false;
- if (isFront) {
- frontPeek = (WindowPeek) FrontWindow ();
- isDesk = (frontPeek->windowKind < 0);
- }
- isText = isCur && (cur->text != nil);
- isScrap = false;
- if (isText) {
- isSelected = ((**(cur->text)).selStart != (**(cur->text)).selEnd);
- isScrap = (TEGetScrapLen () > 0);
- }
-
- menu = FileMenu;
- %if defined FileClose%
- Enable (FileClose, isFront);
- %end if%
- %if defined FileSave%
- Enable (FileSave, isDirty);
- %end if%
- %if defined FileSaveAs%
- Enable (FileSaveAs, isDirty);
- %end if%
- %if defined FileRevert%
- Enable (FileRevert, isDirty && hasFile);
- %end if%
-
- menu = EditMenu;
- if (isFront) {
- %if defined EditUndo%
- Enable (EditUndo, isDesk);
- %end if%
- %if defined EditCut%
- Enable (EditCut, isDesk || isSelected);
- %end if%
- %if defined EditCopy%
- Enable (EditCopy, isDesk || isSelected);
- %end if%
- %if defined EditPaste%
- Enable (EditPaste, isDesk || isScrap);
- %end if%
- %if defined EditClear%
- Enable (EditClear, isDesk || isSelected);
- %end if%
- %if defined EditSelectAll%
- Enable (EditSelectAll, isText);
- %end if%
- }
-
- EnableTitle (EditMenu, isFront);
-
- if (menuBarChanged) {
- DrawMenuBar ();
- }
- } /*UpdateMenus*/
-